package SpringFramework.ApplicationEvent.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class DemoPublisher {
	// 注入ApplicationContext，用来发布事件。
	@Autowired
	private ApplicationContext context;
	
	public void publicsh(String msg) {
		// 发布事件
		context.publishEvent(new DemoEvent(this, msg));
	}
}
